package com.zb.internetSpider.gui.frame;



import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.util.ArrayList;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Component;

import com.zb.internetSpider.gui.SpiderComponent;
import com.zb.internetSpider.gui.SpiderContainer;
import com.zb.internetSpider.gui.Theme;
import com.zb.internetSpider.gui.footerBar.AbstractSpiderFooterBar;
import com.zb.internetSpider.gui.menuBar.AbstractSpiderMenuBar;
import com.zb.internetSpider.gui.splitPanel.AbstractSpiderSplitPane;


//@Component
public class DefaultSpiderFrame extends AbstractSpiderFrame  {
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private static final Logger logger = LogManager.getLogger(DefaultSpiderFrame.class);
	
	/**
	 * 
	
	 * <p>Description: 构建起application的主要界面骨架</p>
	
	 * @param menuBar
	 * @param spiderSplitPane
	 * @param footerBar
	 * @param asiderPanel
	 * @param spiderMainPanel
	 * @param spiderTree
	 * @param spiderTreeModel
	 * @param spiderTabsPanel
	 */
	public DefaultSpiderFrame() {
	}

	public DefaultSpiderFrame(Theme theme) {
		this.theme = theme;
	}
	
	@Override
	public void setTheme(Theme theme) {
		// TODO Auto-generated method stub
		this.theme = theme;		
	}


	@Override
	public void setSpiderContainers(SpiderContainer... containers) {
		// TODO Auto-generated method stub
		for(SpiderContainer container : containers) {
			this.containers.add(container);
		}
		
	}

	@Override
	public void setSpiderComponents(SpiderComponent... components) {
		// TODO Auto-generated method stub
		for(SpiderComponent component : components) {
			this.components.add(component);			
		}
	}

	@Override
	public SpiderContainer[] getSpiderContainers() {
		// TODO Auto-generated method stub
		return this.containers.toArray(new SpiderContainer[0]);
	}

	@Override
	public SpiderComponent[] getSpiderComponents() {
		// TODO Auto-generated method stub
		return this.components.toArray(new SpiderComponent[0]);
	}

	@Override
	public int SpiderContainersCount() {
		// TODO Auto-generated method stub
		return this.containers.size();
	}

	@Override
	public int SpiderComponentsCount() {
		// TODO Auto-generated method stub
		return this.components.size();
	}

	@Override
	public void setFont(Font font, Color color) {
		// TODO Auto-generated method stub
		super.setFont(font);
		super.setForeground(color);
	}

	@Override
	public void setBackGroundColor(Color color) {
		// TODO Auto-generated method stub
		super.setBackground(color);
	}

	@Override
	public void addSpiderContainer(SpiderContainer... containers) {
		// TODO Auto-generated method stub
		
		if(this.containers == null){
			this.containers = new ArrayList<SpiderContainer>();
		}
		
		/**
		 * 添加分割面板
		 */
		Container container = this.getContentPane();
		for(SpiderContainer sContainer: containers) {
			this.containers.add(sContainer);
			if(sContainer instanceof AbstractSpiderFooterBar){
				/**
				 * 添加页脚
				 */
				container.add((AbstractSpiderFooterBar)sContainer, BorderLayout.SOUTH);
			}else if(sContainer instanceof AbstractSpiderSplitPane){
				container.add((AbstractSpiderSplitPane)sContainer, BorderLayout.CENTER);
			}else if(sContainer instanceof AbstractSpiderMenuBar) {
				super.setJMenuBar((AbstractSpiderMenuBar) sContainer);
			}
		}
		
	}

	@Override
	public void create() {
		// TODO Auto-generated method stub
		super.setVisible(true);
	}

	
}
